import axios from "../utils/http";

const MenuStore = {
    namespaced:true,
    state:()=>({
        menuList:[]
    }),
    mutations:{
        menuListMutation(state,list){
            state.menuList = list
        }
    },
    actions:{
        menuListAction(context){
            axios.get("/api/menulist?istree=1").then(res=>{
                console.log(res);
                if(res.code === 403){
                    localStorage.removeItem("login_data")
                    window.location.href = "/#/login"
                }else{
                    if(res.code === 200){
                        context.commit("menuListMutation",res.list)
                    }
                }
            })
            
        }
    }
}

export default MenuStore



